import { createRouter, createWebHashHistory } from 'vue-router';
import Layout from '@/layouts/index.vue';

// 静态路由
export const constantRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: 'login',
    },
    hidden: true,
  },
  {
    path: '/401',
    name: '401',
    component: () => import('@/views/errorPage/401.vue'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/errorPage/404.vue'),
    hidden: true,
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/errorPage/404.vue'),
    hidden: true,
  },
  {
    path: '/prize',
    component: Layout,
    children: [
      {
        path: '/prize',
        component: () => import('@/views/prize/list.vue'),
        name: 'prize',
        meta: {
          title: '核销记录',
          icon: 'fileManagement',
        },
      },
    ],
  },
  {
    path: '/setting',
    component: Layout,
    children: [
      {
        path: '/setting',
        component: () => import('@/views/prize/setting.vue'),
        name: 'setting',
        meta: {
          title: '奖品设置',
          icon: 'fileManagement',
        },
      },
    ],
  },
];

// 动态路由
export const asyncRoutes = [];

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
});

// reset router
export function resetRouter() {
  r; /* outer.getRoutes().forEach((route) => {
    const { name } = route;
    if (name) {
      router.hasRoute(name) && router.removeRoute(name);
    }
  }); */
}

export default router;
